#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin >> t;
    int b[t];
    for(int  i= 0;i < t;i++)
    {
        int n,ans = 0;
        cin >> n;
        int a[n];
        for(int i = 0;i < n;i++)
        {
            cin >> a[i];
        }
        sort(a,a+n);
        for(int i = 0;i < n-1;i++){
            if(a[i] == a[i+1])  ans+=a[i];
        }
        b[i] = ans;
    }
    for(int i = 0;i < t;i++)  cout << b[i] << endl;
    return 0;
}
